<?php

namespace app\api\controller;

use app\common\model\Banner;
use app\common\model\DrawRecord;
use app\common\model\GiftRecord;
use app\common\model\Helpers;
use app\common\model\Room;
use app\common\model\UserGuard;
use app\common\service\AppService;
use app\common\service\ChatService;
use Qiniu\Auth;
use Qiniu\Pili\Mac;
use Qiniu\Tests\PfopTest;
use rongyun\api\RongCloud;
use think\Cache;
use think\Db;
use app\common\model\Users;
use think\Exception;

class Index extends Base
{




    public function _initialize()
    {

        parent::_initialize();
    }

    public function index()
    {
        dd(date(' c '));

//        dd(\cache('smashLog'));

        throw new Exception('测试错误记录');
        phpinfo();exit;
        $ip = request()->ip();
        echo 'api:';
        echo  $ip;exit('endTest');
    }



    /**
     * 获取banner及广告图
     */
    public function getBanner()
    {
        $model = new Banner();
        $where['status'] = 1;
        
        $where['cid'] = input('post.cid')??1;
        $limit = is_numeric(input('post.num')) ? input('post.num') : 6;
        if ($where['cid'] == 2){
            $activity = self::getExplain('activity');
            if ($activity !== 'open'){
                $where['cid'] = 999;
            }
        }
        $rows = $model->getBanner($where,$limit);
        if (!empty($rows)) api_return(1, '获取成功', $rows);
        api_return(0, '暂无数据');
    }


    /**
     * 房间列表
     */
    public function roomList()
    {
        $map['a.status'] = 1;
        $type = input('post.type');
        if (is_numeric($type) && $type != 0){
            $map['a.type'] = $type;

            $where['room_id']       = ['neq',0];
            $where['online_status'] = 1;
            if($type == 4){
                //房间类型为聊天的   只展示有人的房间
                $rooms = Db::name('user_extend')->where($where)->group('room_id')->cache(30)->column('room_id');

                $map['a.room_id'] = ['in',$rooms];
            }

        }else{
            //查询热门 去掉聊天类型房间
            $map['a.type'] = ['neq',4];
            $map['a.top']  = 1;
        }

        if ($map['a.type'] == 2){
            // 2019-8-5 娱乐厅新增细分分类  默认查询分类为娱乐厅  否则查询交友厅
            $map['a.room_type'] = input('post.room_type') == 2 ?2:1;
        }

        $model = new Room();
        $rows = $model->getRows($map,self::getUserId());
        api_return(1,'获取成功',$rows);
    }




    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 获取贵族排行榜
     */
    public function noble()
    {

        $time = cache('nobleTime');
        $map = [];

        if (time()+30 > $time){
            $time = time() + 30;
            cache('nobleTime',$time);
        }

        $map['e.noble_id']   = ['>',0];
        $map['e.noble_time'] = ['>',$time];

        $model = new Users();

        $rows = $model->getNoble($map);

        api_return(1,'获取成功',$rows);

    }

    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 获取CP排行榜
     */
    public function guard()
    {
        $time = cache('guardTime');
        $map = [];

        $id = dehashid(input('post.id'));
        if (is_numeric($id)){
            $map['a.guard_user'] = $id;
        }


        if (time()+86430 > $time){
            $time = time() + 86430;
            cache('guardTime',$time);
        }

        $map['a.status'] = 1;
        $map['a.end_time'] = ['>',$time];

        $model = new UserGuard();
        $rows = $model->getRows($map);

        api_return(1,'获取成功',$rows);

    }


    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 守护排行榜
     */
    public function protect()
    {
        $map['a.status'] = 1;
//        $map['a.room_id'] = ['>',0];
        $model = new GiftRecord();
        $rows = $model->protect($map,self::getUserId());
        api_return(1,'获取成功',$rows);
    }

    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 真爱排行榜
     */
    public function trueLove()
    {

        $map['a.status'] = 1;
        $map['a.room_id'] = ['>',0];
        $map['g.price'] = ['>',519];
        $model = new GiftRecord();

        $rows = $model->getTrueLove($map,self::getUserId());

        api_return(1,'获取成功',$rows);
    }



    /**
     * 发送短信
     */
    public function sms()
    {
        if (request()->isPost()){
            $phone = input('post.phone');
            if (empty($phone)) api_return(0,'手机号码不能为空');
            $has = cache('code_num'.$phone);
            $endToday = strtotime(date('Y-m-d 23:59:59'));
            $time = $endToday - time();
            if ($has){
                if ($has['num'] >= 15)api_return(0,'短信发送过多');
                if ($has['time']+60 > time())api_return(0,'短信发送过于频繁,请一分钟后重试');
            }else{
                cache('code_num'.$phone,['num'=>0,'time'=>time()],$time);
            }
            $result = sendSms($phone);
            if ($result){
                cache('code_num'.$phone,['num'=>$has['num']+1,'time'=>time()],$time);
                api_return(1,'发送成功');
            }else{
                api_return(0,'发送失败');
            }
        }
        api_return(666,999);
    }




    //生成微信分享二维码

    public function shareQrcode(){
        $data = request()->param('url');
        $res = code($data);
        api_return(1,'成功',$res);
    }









    /**
     * 获取扩展
     */
    public function explain()
    {
        $field = input('post.field');
        if (empty($field)) api_return(0,'参数不能为空');
        $rows = self::getExplain($field,true);

        api_return(1,'获取成功',$rows);
    }


    /**
     * 获取融云token
     */
    public function token()
    {
        $token = $this->R_token(self::getUserId());
        if ($token !== false) api_return(1,'获取成功',$token);
        api_return(0,'服务器繁忙,请稍后重试');
    }

    public function callback()
    {
        $data = input();
        $caceh = cache('input_vod_data');
        $caceh[] = $data;
        cache('input_vod_data',$caceh);
    }


    public function callback1()
    {
        $upload_ret =  cache('input_vod_data')[0]['upload_ret'];
//        $upload_ret = Yii::$app->request->get('upload_ret');
        $json_ret = base64_decode($upload_ret);
        $result = json_decode($json_ret);
        // 返回原视屏名称
        $video_url = $result->key;

        // 前面加上new_得到加过水印的视频
        $video_url1 = 'new_'.$result->key;
        dd($upload_ret,$json_ret,$result,$video_url,$video_url1);
        // 地址
        $http = "http://ovu8sm392.bkt.clouddn.com/";
        // 第一帧
        $img = '?vframe/jpg/offset/1';
//        $model = new Video();
//        $model->video_img = $http.'new_'.$video_url.$img;
//        $model->title = 'super good';
//        $model->video_url = $http.'new_'.$video_url;
//        $model->video_length = $model->getVideotime($http.$video_url);
//        $model->save();

        header("Location:/video/list");



    }





    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 广场
     */
    public function square()
    {

        $data = input('post.');

        $user_id = self::getUserId();

        $map = [];

        $map['e.hall'] = 1;
//        if ($user_id > 0){
//            $map['a.user_id'] = ['neq',$user_id];
//        }

        $map['a.status'] = 1;

        if ($data['sex']){
            $map['a.sex'] = $data['sex'];
        }


        $order = 'e.online_status desc';


        if ($this->getSex($user_id) == 1){
            $order .= ',a.sex asc,e.online_time desc';
        }else{
            $order .= ',a.sex desc,e.online_time desc';
        }

        $order .= ',e.noble_id desc';


        if ($data['section']){

            $time = ageDate($data['section']);
            $map['a.birthday'] = ['between time',$time];
        }


        if ($data['skill_id']){
            $skill_id = $data['skill_id'];
            $map['s.skill_id'] = $data['skill_id'];
            //修改大厅必有技能  因此注释此筛选
            $map['s.status']   = 1;
            $map['s.is_use']   = 1;
        }else{
            $skill_id = false;
        }

        //修改大厅非必有技能  因此注释此筛选
//        $map['s.status']   = 1;
//        $map['s.is_use']   = 1;

        if (!empty($data['city'])){
            $map['e.place'] = ['like','%'.trim($data['city']).'%'];
        }

        $model = new Users();
        $rows  = $model->rows($map,$user_id,$order,$skill_id);

        api_return(1,'获取成功',$rows);

    }



    
    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 分类获取
     */
    public function cate()
    {
        $type = input('param.type');
        if (!is_numeric($type)){
            api_return(0,'参数错误');
        }


        $model = new \app\common\model\Skill();

        $map['type'] = $type;

        $rows = $model->getRows($map);

        api_return(1,'获取成功',$rows);

    }


    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 分类详情
     */
    public function detail()
    {
        $id = input('param.id');
        if (!is_numeric($id)){
            api_return(0,'参数错误');
        }
        $map['skill_id'] = $id;
//        $map['status']   = 1;

        $model = new \app\common\model\Skill();

        $data  = $model->getDetail($map);

        api_return(1,'获取成功',$data);

    }

    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 获取帮助文章
     */
    public function helpers()
    {
        $model = new Helpers();
        $rows  = $model->getRows(['status'=>1]);
        api_return(1,'获取成功',$rows);
    }

    public function payDebug()
    {
        dd(cache('msg'), cache('messageData'),cache('message'),cache('wechatMsgData'),cache('wechatMsg'));

    }

    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 融云在线状态改变
     */
    public function online_status()
    {
        $data = input();

        $appSecret = config('rongyun.appSecret');
        $nonce = $data['nonce'];
        $timestamp = $data['timestamp'];

        $signature = sha1($appSecret.$nonce.$timestamp);
        if ($signature == $data['signature']){
            $item = $data[0];
            $user_id = dehashid($item['userid']);

            if (!is_numeric($user_id))  exit('params error');
            $update = [];

            $userExtra = self::userExtra('online_status,room_id',$user_id);

            if ($item['status'] === 0 || $item['status'] === '0'){ //上线

                if ($userExtra['online_status'] == 0){
                    $update['online_status'] = 1;
                    $update['online_time'] = time();
                    //用户上线发送消息至守护用户
                    $str = sprintf('你守护的用户[%s]上线了!',$this->userInfo('nick_name',$user_id));
                    $map['a.guard_user'] = $user_id;
                    $map['a.end_time']   = ['>=',time()];
                    $map['a.status']     = 1;
                    $map['e.online_status'] = 1;
                    Db::name('user_guard')->alias('a')->join('user_extend e','e.user_id = a.user_id')->where($map)->field('a.user_id')->chunk(1000,function ($users)use($str){
                        $uid = [];
                        foreach ($users as $user){
                            $uid = hashid($user['user_id']);
                        }
                        self::sendUsrMsg('system',$uid,$str);
                    });
                }

            }else{ //离线

                //复查是否真实离线
                $online = ChatService::getInstance()->user()->checkOnline($item['userid']);

                $array = json_decode($online,true);

                if ($array['code'] && $array['status'] == 0){
//                    $room_id = $userExtra['room_id'];
//                    if ($room_id){
//                        $refresh = self::outRoomFunc($user_id,$room_id);
//                        if ($refresh){
//                            //需要刷新麦序
//                            $this->refreshWheat($room_id);
//                        }
//                    }
                    $update['online_time'] = time();
                    $update['room_id'] = 0;
                    $update['online_status'] = 0;
                }

            }
            if (!empty($update)){
                self::updateUserExtend($user_id,$update);
            }
            exit('success');
        }else{
            exit('params error');
        }
    }

    /**
     * 声网服务状态
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     */
    public function voice_status()
    {
        $data = input('post.');
        $cache = cache('voice_status');

//        $data = $cache[3];

        $secret = 'ou8Wvbw0o';

//        $agoraSigntrue = request()->header('Agora-Signature');
////        $agoraSigntrue = 'b79b8d6b2d93c0346103c188eb2d37c1c6698646';
//
//        $json = json_encode($agoraSigntrue);
//
//        $sign = hash_hmac('sha1',$json,$secret);
////
//        if ($agoraSigntrue !== $sign){
//            api_return(0,'签名错误');
//        }

        if ($data['eventType'] == 104 || $data['eventType'] == 106){
            $user_id = Db::name('users')->where('uuid',$data['payload']['uid'])->cache(5)->value('user_id');
            if (!isInt($user_id)){
                api_return(0,'用户不存在');
            }

            $room_id = $data['payload']['channelName'];

            $refresh = self::outRoomFunc($user_id,$room_id);

            if ($refresh){
                $this->refreshWheat($room_id);

            }
            api_return(1,'成功');
        }


    }


    /**
     * 官网宣传页
     */
    public function web()
    {
        $rows = self::getExplain('companyName,url,IPC,companyAddress,ios,andriod,webKeywords,webDescription,webTitle,phone');
        $this->assign([
            'rows' => $rows,
        ]);
        return view();
    }

    /**
     * 官网关于我们
     */
    public function about()
    {
        $rows = self::getExplain('companyName,url,IPC,companyAddress,ios,andriod,webKeywords,webDescription,webTitle,phone');
        $this->assign([
            'rows' => $rows,
        ]);
        return view();
    }


    /**
     * 官网服务和隐私协议
     */
    public function service()
    {
        $rows = self::getExplain('companyName,url,IPC,companyAddress,ios,andriod,webKeywords,webDescription,webTitle,phone');
        $this->assign([
            'rows' => $rows,
        ]);
        return view();
    }

    public function yx()
    {
        $rows = self::getExplain('companyName,url,IPC,companyAddress,ios,andriod,webKeywords,webDescription,webTitle,phone');
        $this->assign([
            'rows' => $rows,
        ]);
        return view();
    }

    public function zb()
    {
        $rows = self::getExplain('companyName,url,IPC,companyAddress,ios,andriod,webKeywords,webDescription,webTitle,phone');
        $this->assign([
            'rows' => $rows,
        ]);
        return view();
    }

    /**
     * 官网用户协议
     */
    public function agree()
    {
        $rows = self::getExplain('companyName,url,IPC,companyAddress,ios,andriod,webKeywords,webDescription,webTitle,phone');
        $this->assign([
            'rows' => $rows,
        ]);
        return view();
    }

    public function show()
    {
        api_return(0,'登录过期',new EmptyC());
    }


    /**
     * 下载跳转页
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     */
    public function download()
    {
        $type = get_device_type();
        if ($type == 'ios'){
            $url = self::getExplain('ios');
        }else{
            $url = self::getExplain('andriod');
        }


        $this->redirect($url);
    }



    /**
     * Created by xiaosong
     * E-mail:306027376@qq.com
     * 礼物列表
     */
    public function giftList($type = false)
    {
        $model = new \app\common\model\Gift();

        $map['status'] = 1;

        $rows = $model->giftList($map,$type,self::getUserId());

        api_return(1,'获取成功',$rows);

    }

    public function sss()
    {
        /* 永不超时 */
        ini_set('max_execution_time', 0);
       $rows =  Db::name('my_package')->where('type',1)->select();
       $array = [];
       foreach ($rows as $k => $v){

           $map['user_id'] = $v['user_id'];
           $map['key']     = $v['key'];
           $map['type']    = 1;
           $map['p_id']     = ['neq',$v['p_id']];
           $next = Db::name('my_package')->where($map)->find();
           if ($next && $next['num'] >= 0){
               if ($next['num'] <= $v['num']){
                    $id = $next['p_id'];
                    $array[] = $v['p_id'];
               }else{
                    $id = $v['p_id'];
                   $array[] = $next['p_id'];
               }
               if (is_numeric($id) && !in_array($id,$array)){

                   $data = Db::name('my_package')->where('p_id',$id)->delete();
                    dump($data,$id);
               }
           }

       }
    }

    public function sssss()
    {

        $map['type']    = 1;
        $map['num']     = 0;
        $num = Db::name('my_package')->where($map)->delete();
        dd($num);
    }


    /**
     * 手气排行榜
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     */
    public function RankingList()
    {
        $model = new DrawRecord();
        $map = [];
        $map['a.price'] = ['>=',self::getExplain('mini_price')];
        $rows = $model->getRanks($map,self::getUserId());
        api_return(1,'获取成功',$rows);

    }

    public function ssss()
    {
        dd(cache('message'),cache('messageData'),cache('wechatMsgData'),cache('wechatMsg'));
    }

    /**
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     * 帮助文章
     */
    public function helper()
    {
        $id = input('id');
        $detail = Db::name('helpers')->where('h_id',$id)->cache(15)->find();
        $this->assign([
            'detail' => $detail,
        ]);
        return view();
    }

    public function test()
    {


        /* 永不超时 */
        ini_set('max_execution_time', 0);
        $model = new GiftRecord();

        $map['after_total'] = 0;

        Db::name('gift_record')->where($map)->chunk(1000,function ($items)use($model){

            foreach ($items as $k => $v){
                $items[$k]['after_total'] = $v['total'] * 0.7;
            }

            $model->saveAll($items);

        });
        dd('xxx');


//        dd(getThumb('http://file.mengpaxing.com/1562179713649.png'));
//
//        dd(strlen('FvwUWdmcWeVM4HbL1yCKr0q0ji6A'));
//        dd(request()->path());
//        dd(cache('login_array'));
//        self::replaceDatabaseStr('http://file.51soha.com/default_header.jpg','http://file.mengpaxing.com/ecc5b201901151032276465.png');
    }

    /**
     * ios强制更新
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     */
    public function iosVersion1()
    {
        $row['pg_zs_bb'] = 1;  // 正式版 版本号    （客户端 版本号 小于 ios_release_version  则需要更新）
        $row['pg_cs_bb'] = 1; //测试版本 版本号    （测试版本号 永远比 正式版本 号 大0.1，上架成功 之后版本修改）
        $row['pg_gxdz']  = "https://itunes.apple.com/us/app/%E7%BB%BF%E8%89%B2%E5%AE%B6%E5%9B%AD-%E7%94%9F%E9%B2%9C%E5%95%86%E5%9F%8E/id1441401041?l=zh&ls=1&mt=8"; //更新地址 （  客户端版本低于正式版版本 弹出更新）
        $row['pg_gxnr']  = "新版本AppStore已更新请及时下载;"; //更新内容
        $row['pg_qzgx']  = 1; //是否需要 强制更新
        $row['pg_zzsh']  = 1; //是否正在审核，(前端判定版本号 == 测试
        $row['pg_xsrz']  = 1; //是否需要展示ios日志

        api_return(1,'获取成功',$row);

    }


    public function iosVersion()
    {
        $field = "pg_xsrz,versionCode as pg_zs_bb,versionName as pg_cs_bb,`force` as pg_qzgx,url as pg_gxdz,detail as pg_gxnr,pg_zzsh";
        $new = Db::name('version')->where('type',2)->fieldRaw($field)->order('id desc')->cache(15)->find();
        if (!empty($new)){
            $new['show'] = self::getExplain('show');
            api_return(1,'获取成功',$new);
        }
        api_return(0,'系统错误');

    }


    /**
     * 版本控制
     */
    public function version()
    {
        $new = Db::name('version')->where('type',1)->field('versionCode,versionName,force,url,detail')->order('id desc')->cache(15)->find();
        if (!empty($new)){

            $new['domain'] = self::getExplain(get_device_type().'Url');

//            if ($m % 2 == 0){
//                $new['domain'] = 'http://api.mengpaxing.com/';
//            }else{
//                $new['domain'] = 'http://alpha.mengpaxing.com:9999/?s=/';
//            }


            $new['show'] = self::getExplain('show');
            $new['fanHidden'] = self::getExplain('fanHidden');
            $new['eggHidden'] = self::getExplain('eggHidden');

            api_return(1,'获取成功',$new);
        }
        api_return(0,'系统错误');
    }


    /**
     * 测试付款
     * Created by xiaosong
     * E-mail:4155433@gmail.com
     */
    public function testPay()
    {
        $appkey = 'hlJget46aQOxC9GO7j05IRpiG818c9Fh';
        $des3key = 'ssSddU2R2qI6zdSQeCl4vRAt';


//        $des3key = '123456788765432112345678';
//        $desUtils = new DesUtils($des3key);
        $order = time();
        //支付宝data
//        $data = <<<EOF
//{"order_id": "$order","dealer_id": "07821809","broker_id":
//"yiyun73","real_name": "邢卓松","card_no": "18181366398","id_card": "513901199612293932","pay": "1.00"}
//EOF;
        //银行卡data
                $data = <<<EOF
{"order_id": "$order","dealer_id": "07821809","broker_id":
"yiyun73","real_name": "邢卓松","card_no": "62122610010632884995","id_card": "513901199612293932","pay": "1.00","notify_url": "https://api.mengpaxing.com/index/callNotify.html"}
EOF;

        $url = 'https://api-jiesuan.yunzhanghu.com';

        $time = 1559029223;

        $mess = '123456';


        $result = encrypt($data,$des3key);

        $sign = hash_hmac('sha256',"data=$result&mess=$mess&timestamp=$time&key=$appkey",$appkey);

        $array['data'] = $result;
        $array['mess'] = $mess;
        $array['timestamp'] = $time;
        $array['sign']  = $sign;
        $array['sign_type'] = 'sha256';

        makeOrder($url.'/api/payment/v1/order-realtime',$array);

        dd($result,$sign);
        $alipay = ' /api/payment/v1/order-alipay';

        $order['order_id'] = '1';
        $dealer_id =  "07821809"; # 商户代码(必填)
        $broker_id =  "yiyun73"; # 代征主体(必填)
        $real_name =  "邢卓松"; # 姓名(必填)
        $id_card =  "513901199612293932"; # 身份证(必填)
        $card_no =  "18181366398"; # 收款⼈人⽀支付宝账户(必填)
        $pay =  "1.00" ;# 打款⾦金金额（单位为元, 必填）
        $notes =  "备注信息"; # 备注信息(选填)
        $pay_remark =  ""; # 打款备注(选填，最⼤大20个字符，⼀一个汉字占2个
        //字符，不不允许特殊字符：' " & | @ % * ( ) - : # ￥)
        $check_name = "NoCheck"; # 校验⽀支付宝账户姓名，可填 Check、NoCheck
        $notify_url =  "" ;# 回调地址(选填，最⼤大⻓长度为200)



        echo "result: $result\n";
        $a = (object) [1,2];
    }

    public function testPay2()
    {
        $appkey = 'hlJget46aQOxC9GO7j05IRpiG818c9Fh';
        $des3key = 'ssSddU2R2qI6zdSQeCl4vRAt';

        $order = 7;
        //支付宝data
//        $data = <<<EOF
//{"order_id": "$order","dealer_id": "07821809","broker_id":
//"yiyun73","real_name": "邢卓松","card_no": "18181366398","id_card": "513901199612293932","pay": "1.00"}
//EOF;
        //银行卡data
        $data = <<<EOF
{"order_id": "$order"}
EOF;

        $time = 1559029223;

        $result = encrypt($data,$des3key);

        $sign = hash_hmac('sha256',"data=$result&mess=123456&timestamp=$time&key=$appkey",$appkey);
        dd($result,$sign);
        $url = 'https://api-jiesuan.yunzhanghu.com';
        $alipay = ' /api/payment/v1/order-alipay';

        $order['order_id'] = '1';
        $dealer_id =  "07821809"; # 商户代码(必填)
        $broker_id =  "yiyun73"; # 代征主体(必填)
        $real_name =  "邢卓松"; # 姓名(必填)
        $id_card =  "513901199612293932"; # 身份证(必填)
        $card_no =  "18181366398"; # 收款⼈人⽀支付宝账户(必填)
        $pay =  "1.00" ;# 打款⾦金金额（单位为元, 必填）
        $notes =  "备注信息"; # 备注信息(选填)
        $pay_remark =  ""; # 打款备注(选填，最⼤大20个字符，⼀一个汉字占2个
        //字符，不不允许特殊字符：' " & | @ % * ( ) - : # ￥)
        $check_name = "NoCheck"; # 校验⽀支付宝账户姓名，可填 Check、NoCheck
        $notify_url =  "" ;# 回调地址(选填，最⼤大⻓长度为200)



        echo "result: $result\n";
        $a = (object) [1,2];
    }





    public function callNotify()
    {
        $data = input();
        $array = cache('callNotify');
        $array[] = $data;
        cache('callNotify',$array);
    }

    public function test3()
    {
        getStatus('https://api-jiesuan.yunzhanghu.com/api/payment/v1/query-realtime-order');
    }

    public function test12()
    {

        $appkey = 'hlJget46aQOxC9GO7j05IRpiG818c9Fh';
        $des3key = 'ssSddU2R2qI6zdSQeCl4vRAt';

        $desUtils = new DesUtils($des3key);

        $data = decrypt('ravI1idG7NrQQX6X9XsP5AiyBldvdWy7bWN2AVLgttiSE3bcX/kygI/AMnD3gOd5jEkOvKnpFMLf9H14mbi2wjCDL/hDxYuq32MX3i7MZ6I2JSFqkjLgl3DxEZ4Nt/fy5yCvEJuLfIf31vRLjMVzCFILj20DI5k9ZesuWk8qm22AtQ55md55pYJt3zGipxmV7c4xLJeRUHjvdvs4Xd0nIF1QGDiHSqVd/FpPeb4jiUyrEC0rVXo1M4y+nporLR/+5K7FkMZlse64dD22XyIvJWY/M/Oj3M/+KuuCIesJhu6lwX7xwU+Og4HME5OqqkqAtZ4YC2HXo+uR2VjD8/v+ZfJw1u+CRtrSePHHX0DyJCMEPuQboWHgACsjj5auVf0mL5gHQVyNwyAoGL+jt1HMogbIMYQtkxb8SHP1NJnwi21P0wdH302HWGCb5ViCLsScJO6zf0377+jYORwE3IfvtUivKRJWoaMV31Wimc4XXgQWP9DhcQguhkyj7yv/U3ozDxEu8uCqSvQXBLAPGvA3F7zUrpJbJF+XsLMKeI5FPCjWPh2WQCiioKe8dDzw1xfCqS9Hfmu/6etQzpzRbo0hj0FMq1+CO038CA6S9EfwDwN82tfNZgU7JYqIBO0Pn705F59vxOq5pjQVCXF4QWVEKmBFDSvraJKZO4APLFfCs7KDiYJLn8hr+zILBxWFlkqXQH0juOjamp7MqAmwjqovbHyGPHiRayL19NP7Oc0vjOtcKbxeHUKH5g==',$des3key);
dd(json_decode($data));
//        dd(cache('callNotify'));
    }

}
//class DesUtils
//{
//    private $des3key; // 密钥向量量
//    private $iv; // 混淆向量量
//
//    /**
//     * 构造，传递⼆二个已经进⾏行行base64_encode的KEY与IV
//     *
//     * @param string $des3key
//     * @param string $iv
//     */
//    function __construct($des3key, $iv = null)
//    {
//        $this->des3key = $des3key;
//        $this->iv = $iv;
//    }
//
//
//    /**
//     * 加密
//     * @param <type> $value
//     * @return <type>
//     */
//    public function encrypt($value,$des3key)
//    {
//        $iv = substr($this->des3key, 0, 8);
//        $ret = openssl_encrypt($value, 'DES-EDE3-CBC', $this->des3key, 0, $iv);
//        if (false === $ret) {
//            return openssl_error_string();
//        }
//        return $ret;
//    }
//
//
//    /**
//     * 解密
//     * @param <type> $value
//     * @return <type>
//     */
//    public function decrypt($value)
//    {
//        $iv = substr($this->des3key, 0, 8);
//        $ret = openssl_decrypt($value, 'DES-EDE3-CBC', $this->des3key, 0, $iv);
//        if (false === $ret) {
//            return openssl_error_string();
//        }
//        return $ret;
//    }
//
//
//}